package net.caixiaomi.info.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import net.caixiaomi.info.R;
import net.caixiaomi.info.base.quickadapter.BaseQuickAdapter;
import net.caixiaomi.info.base.quickadapter.BaseViewHolder;
import net.caixiaomi.info.base.quickadapter.entity.MultiItemEntity;
import net.caixiaomi.info.model.DiscoveryHallEntity;
import net.caixiaomi.info.model.DiscoveryHotLeagueEntity;
import net.caixiaomi.info.model.HomePlayClassifyItem;
import net.caixiaomi.info.util.Constants;

/**
 * Created by mac on 18/9/4.
 */

public class DiscoveryGridAdapter extends BaseQuickAdapter<MultiItemEntity, BaseViewHolder> {
    public DiscoveryGridAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, MultiItemEntity item) {
        try {
            String name = "";
            String Imgurl = "";
            if (item.getItemType() == Constants.ITEM_MATCH_LIVE0) {
                DiscoveryHallEntity hall = (DiscoveryHallEntity) item;
                name = hall.getClassName();
                Imgurl = hall.getClassImg();
            } else {
                DiscoveryHotLeagueEntity league = (DiscoveryHotLeagueEntity) item;
                name = league.getLeagueAddr();
                Imgurl = league.getLeaguePic();
            }
            helper.setText(R.id.title, name);
            ImageView imageView = helper.getView(R.id.image);
            Glide.with(imageView.getContext()).load(Imgurl).into(imageView);
        }catch (Exception e){

        }
    }
}
